package org.fatmansoft.teach.controllers;

import org.fatmansoft.teach.payload.request.DataRequest;
import org.fatmansoft.teach.payload.response.DataResponse;
import org.fatmansoft.teach.service.DailyActivityService;
import org.fatmansoft.teach.service.StudentLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/log")
public class LogController {
    @Autowired
    StudentLogService studentLogService;

    @PostMapping("/getLogs")
    public DataResponse getLogs(@Valid @RequestBody DataRequest dataRequest) {
        return studentLogService.findAllLogByPersonNameAndDate(dataRequest);
    }

    @PostMapping("/editLog")
    public DataResponse editLog(@Valid @RequestBody DataRequest dataRequest) {
        return studentLogService.logEditSave(dataRequest);
    }

    @PostMapping("/createLog")
    public DataResponse createLog(@Valid @RequestBody DataRequest dataRequest) {
        return studentLogService.createLog(dataRequest);
    }
    @PostMapping("/deleteLog")
    public DataResponse deleteLog(@Valid @RequestBody DataRequest dataRequest) {
        return studentLogService.deleteLog(dataRequest);
    }
    @PostMapping("/examineLog")     //管理员审核日志接口。只改变日志的code值
    public  DataResponse examineLog(@Valid @RequestBody DataRequest dataRequest){
        return studentLogService.examineLog(dataRequest);
    }
}
